extends IStateCondition


class_name StateInvokeCondition



## 适配的对象
@export var wrapper: Node = null
## 状态名称
@export var state: FiniteState = null


var __state_duration: float = 0


func __check_exports() -> Dictionary:
    return IComponent.merge({
        "wrapper": func(): return wrapper != null,
        "state": IComponent.find_parent.bind(self, func(x): return x is FiniteState, state),
    }, super.__check_exports())

## 状态进入时
func enter() -> void:
    super.enter()
    __state_duration = 0
    wrapper.condition_enter(state)

## 状态退出时
func exit() -> void:
    wrapper.condition_exit(state)
    super.exit()

## 状态迭代
func update(delta: float) -> void:
    __state_duration += delta
    if wrapper.condition_update(state, delta, __state_duration):
        jump()
